<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
	<xsl:param name="DOTNET2"/>
	
	<xsl:template name="replace-string">
		<xsl:param name="text"/>
		<xsl:param name="replace"/>
		<xsl:param name="with"/>
		<xsl:choose>
			<xsl:when test="contains($text,$replace)">
				<xsl:value-of select="substring-before($text,$replace)"/>
				<xsl:value-of select="$with"/>
				<xsl:call-template name="replace-string">
					<xsl:with-param name="text" select="substring-after($text,$replace)"/>
					<xsl:with-param name="replace" select="$replace"/>
					<xsl:with-param name="with" select="$with"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<xsl:template match="Instance">
	
// REMEMBER TO DERIVE FROM INSTANCE AND NOT ACTUALLY
// USE THIS FOR ANY LOGIC YOU WISH TO WRITE AS IT WILL
// GET OVERWRITTEN ON THE NEXT GENERATION

// ***************************************************************
// Automatically generated from CodeGen2007
// Project Name: <xsl:value-of select="HeaderInfo/ProjectName"/>
// Prefix: <xsl:value-of select="HeaderInfo/Prefix"/>
// ***************************************************************


/*
	
INSTANCE <xsl:value-of select="Name"/> LAYOUT
---------------------------------------------------------------------------

<xsl:for-each select="ClassAttribs/ClassAttributes">

<xsl:value-of select="Name"/> <xsl:if test="CType='array'">[]</xsl:if> (<xsl:value-of select="Type"/>)

</xsl:for-each>
---------------------------------------------------------------------------


*/

using System;
using System.Xml;
using System.Xml.Serialization;

using System.Collections;

using <xsl:value-of select="HeaderInfo/ProjectName"/>.DataObject;

#if(AJAXPRO)
using AjaxPro;
#endif

namespace  <xsl:value-of select="HeaderInfo/ProjectName"/>.Instance
{

	[Serializable]
	public abstract class <xsl:value-of select="Name"/> : <xsl:value-of select="HeaderInfo/ProjectName"/>InstanceObject
	{
	
		
		public <xsl:value-of select="Name"/>() : base() {}
		
		public <xsl:value-of select="Name"/>( int timezoneOffset ) : base(timezoneOffset) {
		
		}
		
		
		public abstract <xsl:value-of select="Name"/> GetInstance();
		public abstract bool HandleIncoming ( <xsl:value-of select="Name"/> @object , string method );
		
		public abstract bool Save ( bool unique , <xsl:value-of select="HeaderInfo/ProjectName"/>InstanceObject obj );
		public abstract <xsl:value-of select="HeaderInfo/ProjectName"/>InstanceObject Load ( bool unique , Guid id );
		public abstract bool Delete ( bool unique , Guid id );	
		
		
		public abstract <xsl:value-of select="Name"/> GetLoaded ( string name , string value ) ;

	
		public override bool Validate(out string[] warning, out string[] error) {
			warning = null;
			error = null;
			
			// Need to implement a generic validation test here
			
			return false;
		}
		

		
		
		<xsl:apply-templates select="ClassAttribs"/>
		
	
	}

}

	</xsl:template>
	
	
	
	
	<xsl:template match="ClassAttribs">
		// fields and attributes of the system
#region Fields and Properties
		<xsl:apply-templates select="ClassAttributes"/>
#endregion
	</xsl:template>
	
	
	<xsl:template match="ClassAttributes">
		<xsl:if test="CType='single' and Type!='DateTime'">
		protected <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="Name"/><xsl:if test="Type='DateTime'">=DateTime.Now</xsl:if><xsl:if test="KnownClass='true'">=new <xsl:value-of select="Type"/>()</xsl:if><xsl:if test="Type='string'">=""</xsl:if>;
		[Sequence(<xsl:value-of select="position()"/>)]
		public <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="PropertyName"/> {
			get { return <xsl:value-of select="Name"/>; }
			set { base.dirty=true; this.<xsl:value-of select="Name"/>=value; }
		}
	</xsl:if>

		<xsl:if test="IsEnum='true'">
			
		public abstract string[] <xsl:value-of select="PropertyName"/>_VALS { get; }
			
		</xsl:if>
		
		
		
		<xsl:if test="KnownClass='true'">
		
		[XmlIgnore]
		public abstract <xsl:value-of select="Type"/>.<xsl:value-of select="Type"/>Small[] <xsl:value-of select="PropertyName"/>_VALS { get; }
		

		
		public Guid <xsl:value-of select="PropertyName"/>Guid
		{
			get
			{
				return <xsl:value-of select="Name"/>.ObjectID;
			}
			
			
			set
			{
				<xsl:value-of select="Name"/> = new <xsl:value-of select="Type"/> ( value );
			}
		
		}
		
		</xsl:if>
        
        <xsl:if test="CType='single' and Type='DateTime'">
		protected <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="Name"/><xsl:if test="Type='DateTime'">=DateTime.Now</xsl:if><xsl:if test="KnownClass='true'">=new <xsl:value-of select="Type"/>()</xsl:if><xsl:if test="Type='string'">=""</xsl:if>;
		
		[Sequence(<xsl:value-of select="position()"/>)]
		public <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="PropertyName"/> {
			get 
			{ 
				return <xsl:value-of select="Name"/>.AddMinutes ( timezoneOffset );
			}
			
			set 
			{ 
				base.dirty=true; 
				<xsl:value-of select="Name"/>=( ( DateTime ) value ).AddMinutes ( timezoneOffset * -1 );
			}
		}
		
		[DateTimeFormatObject]
		public string<xsl:text> </xsl:text><xsl:value-of select="PropertyName"/>_DT {
			get 
			{ 
				return <xsl:value-of select="PropertyName"/>.ToString("dd MMM yyyy HH:mm"); 
			}
			
			set 
			{ 
				// needs error checking
				<xsl:value-of select="PropertyName"/>=DateTime.Parse(value); 
			} 
		}
		
		</xsl:if>
		
		<xsl:if test="CType='array'">
		protected ArrayList <xsl:value-of select="Name"/>=new ArrayList();
		
		[ALAttrib(typeof(<xsl:value-of select="Type"/>))]
        [XmlArrayItem("<xsl:if test="substring(PropertyName,string-length(PropertyName),1)='s'"><xsl:value-of select="substring(PropertyName,1,string-length(PropertyName)-1)"/></xsl:if><xsl:if test="substring(PropertyName,string-length(PropertyName),1)!='s'"><xsl:value-of select="PropertyName"/>_</xsl:if>",typeof(<xsl:value-of select="Type"/>))]
		[Sequence(<xsl:value-of select="position()"/>)]
		public ArrayList <xsl:value-of select="PropertyName"/> {
			get { return <xsl:value-of select="Name"/>; }
			set { base.dirty=true; this.<xsl:value-of select="Name"/>=value; }
		}	
		</xsl:if>
		
		<xsl:if test="ToString='true'">
		public override string ToString() { return <xsl:value-of select="Name"/>.ToString(); }
		</xsl:if>
        
        
        <xsl:if test="Compare='true'">
        public int CompareTo(object obj) {
            return ((<xsl:value-of select="/Class/Name"/>)obj).<xsl:value-of select="PropertyName"/>.CompareTo(<xsl:value-of select="Name"/>);
        }
        </xsl:if>
        
        
        

	</xsl:template>


</xsl:stylesheet>